namespace XRM.Security.DataAccess.Context
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.DepartmentAddress",
                c => new
                    {
                        DepartmentAddressId = c.Int(nullable: false, identity: true),
                        Address = c.String(nullable: false, maxLength: 250),
                        DepartmentId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.DepartmentAddressId)
                .ForeignKey("dbo.Department", t => t.DepartmentId, cascadeDelete: true)
                .Index(t => t.DepartmentId);
            
            CreateTable(
                "dbo.Department",
                c => new
                    {
                        DepartmentId = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 100),
                    })
                .PrimaryKey(t => t.DepartmentId);
            
            CreateTable(
                "dbo.SertificateFsb",
                c => new
                    {
                        SertificateFsbId = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 250),
                        SkziKindId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.SertificateFsbId)
                .ForeignKey("dbo.SkziKind", t => t.SkziKindId, cascadeDelete: true)
                .Index(t => t.SkziKindId);
            
            CreateTable(
                "dbo.SkziKind",
                c => new
                    {
                        SkziKindId = c.Int(nullable: false, identity: true),
                        FullName = c.String(nullable: false, maxLength: 200),
                        ShortName = c.String(nullable: false, maxLength: 100),
                        RegistrNumber = c.String(nullable: false, maxLength: 200),
                        OperationDocName = c.String(maxLength: 200),
                        TechnikalDocName = c.String(maxLength: 200),
                    })
                .PrimaryKey(t => t.SkziKindId);
            
            CreateTable(
                "dbo.SertificateFstk",
                c => new
                    {
                        SertificateFstkId = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 250),
                        SkziKindId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.SertificateFstkId)
                .ForeignKey("dbo.SkziKind", t => t.SkziKindId, cascadeDelete: true)
                .Index(t => t.SkziKindId);
            
            CreateTable(
                "dbo.SystemUser",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Login = c.String(nullable: false, maxLength: 50),
                        FirstName = c.String(nullable: false, maxLength: 50),
                        LastName = c.String(nullable: false, maxLength: 50),
                        MotherName = c.String(maxLength: 50),
                        Post = c.String(nullable: false, maxLength: 500),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.SertificateFstk", "SkziKindId", "dbo.SkziKind");
            DropForeignKey("dbo.SertificateFsb", "SkziKindId", "dbo.SkziKind");
            DropForeignKey("dbo.DepartmentAddress", "DepartmentId", "dbo.Department");
            DropIndex("dbo.SertificateFstk", new[] { "SkziKindId" });
            DropIndex("dbo.SertificateFsb", new[] { "SkziKindId" });
            DropIndex("dbo.DepartmentAddress", new[] { "DepartmentId" });
            DropTable("dbo.SystemUser");
            DropTable("dbo.SertificateFstk");
            DropTable("dbo.SkziKind");
            DropTable("dbo.SertificateFsb");
            DropTable("dbo.Department");
            DropTable("dbo.DepartmentAddress");
        }
    }
}
